package connect 
{
	import adobe.utils.MMExecute;
	/**
	 * ...
	 * @author chitose
	 */
	public class Jsfl 
	{
		
		public function Jsfl() 
		{
		}
		
		static public function trace(str:String):void {
			MMExecute("fl.trace(\'" + str + "\')");
		}
		
		static public function getDocument():Number{
			return Number(MMExecute("fl.documents.length"));
		}
		
		static public function getPathURI():String{
			return MMExecute("fl.getDocumentDOM().pathURI;");
		}
		
		static public function getCreateJSToolkitData():Array{
			var res:String = MMExecute('fl.getDocumentDOM().getDataFromDocument("CreateJSToolkit_data");');
			return res.split("\n");
		}
		
		static public function getCreateJSToolkitData2():Array 
		{
			var res = MMExecute('fl.getDocumentDOM().getDataFromDocument("CreateJSToolkit_data2");');
			return res.split("\n");
		}
		
		static public function runJSFL(string:String, ...rest:Array):*
		{
			//Jsfl.trace(string)
			var str:String = "fl.runScript(fl.configURI + '" + string + "'";
			for (var i:uint = 0; i < rest.length; i++ ) {
				str += ",\'" + rest[i] + "\'";
			}
			str += ")";
			var res =MMExecute(str);
			//Jsfl.trace(string+"/end")
			return res
		}
		
		static public function getModificationDate(str:String):String 
		{
			return MMExecute("FLfile.getModificationDate('" + str + "')");
		}
		
		static public function exists(string:String):String 
		{
			return MMExecute("FLfile.exists(fl.configURI + '"+string+"')");
		}
	}

}